from typing import Optional

from pydantic import BaseModel

from app.models.doctors import ScheduleType, ShiftType
from app.schemas.users import (
    UserCreateSchema,
    UserListViewSchema,
    UserSchema,
    UserUpdateSchema,
)


class ModalityCreateSchema(BaseModel):
    code: str
    name: str


class ModalityUpdateSchema(BaseModel):
    name: str


class ModalitySchema(ModalityCreateSchema):
    pass


class DoctorCreateSchema(BaseModel):
    create_user_schema: UserCreateSchema
    main_modality_code: str
    additional_modalities_codes: list[str]
    rate_percent: int
    preferred_schedule: Optional[ScheduleType] = None
    preferred_shift: Optional[ShiftType] = None


class DoctorUpdateSchema(BaseModel):
    update_user_schema: Optional[UserUpdateSchema] = None
    main_modality_code: Optional[str] = None
    additional_modalities_codes: Optional[list[str]] = None
    rate_percent: Optional[int] = None
    preferred_schedule: Optional[ScheduleType] = None
    preferred_shift: Optional[ShiftType] = None


class DoctorListViewSchema(BaseModel):
    user: UserListViewSchema
    main_modality: ModalitySchema
    additional_modalities: list[ModalitySchema]
    rate_percent: int
    preferred_schedule: Optional[ScheduleType] = None
    preferred_shift: Optional[ShiftType] = None


class DoctorSchema(DoctorListViewSchema):
    user: UserSchema
